package com.yiqi.liebang.feature.people.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.entity.bo.UserInfoBo;
import com.yiqi.liebang.entity.bo.FriendBo;
import com.yiqi.liebang.entity.bo.PeopleBo;
import com.yiqi.liebang.entity.bo.RegisterBo;
import com.yiqi.liebang.entity.bo.SearchBo;
import com.yiqi.liebang.feature.login.contract.LoginContract;
import com.yiqi.liebang.feature.login.dependencies.login.DaggerLoginModelComponent;
import com.yiqi.liebang.feature.people.contract.PeopleContract;
import com.yiqi.liebang.feature.people.dependencies.people.DaggerPeopleModelComponent;
import com.yiqi.liebang.framework.api.ApiLib;
import com.yiqi.liebang.framework.api.UserApi;

import javax.inject.Inject;

import io.reactivex.Observable;

public class PeopleModel implements PeopleContract.Model {

    @Inject
    UserApi api;


    @Inject
    public PeopleModel() {
        DaggerPeopleModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<FriendBo> searchPeople(SearchBo registerBo) {
        return api.searchFriends(registerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> commitAddFriend(PeopleBo registerBo) {
        return api.getAddFriend(registerBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
